package com.trkj.controller;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojos.CcElectornicCheck;
import com.trkj.pojos.CcElectornicPrescribe;
import com.trkj.pojos.CcHospitalElectronic;
import com.trkj.pojos.JlCheckProject;
import com.trkj.pojos.YzrPharStock;
import com.trkj.service.CcHospitalElectronicService;
import com.trkj.vo.CcHospCheckVo;
import com.trkj.vo.CcHospitalElectronicVo;
import com.trkj.vo.HospEleVo;
import com.trkj.vo.Result;

@Controller
public class CcHospitalElectronicController {

	@Autowired
	private CcHospitalElectronicService cchospeleService;
	
	@RequestMapping("/tocc_queryAllhospEle")
	public @ResponseBody Map<String, Object> queryAllhospEle(int page,int rows,String docterid){
		return cchospeleService.queryAllcchospele(page, rows,docterid);
	}
	@RequestMapping("/tocc_queryByhospelepname")
	public @ResponseBody List<CcHospitalElectronicVo> queryBypname(int page,int rows,String pname){
		//System.err.println(pname);
		return cchospeleService.queryBypatientName(page, rows, pname);
	}@RequestMapping("/tocc_queryByhospelepicid")
	public @ResponseBody List<CcHospitalElectronicVo> queryBypicid(int page,int rows,String icid){
		return cchospeleService.queryBypatienticid(page, rows, new BigDecimal(icid));
	}
	@RequestMapping("/tocc_queryBymaiMoney")
	public @ResponseBody YzrPharStock cc_queryBymaiMoney(String pharStockMedId){
		return cchospeleService.queryBypharStockMedId(pharStockMedId);
	}
	@RequestMapping("/tocc_queryAllYp")
	public @ResponseBody Map<String, Object>  queryAllYp(int page,int rows){
		return cchospeleService.queryAllYp(page,rows);
	}
	@RequestMapping("/tocc_queryAllLikeYp")
	public @ResponseBody List<YzrPharStock> queryLikeYp(String pharStockMedName){
		return cchospeleService.queryLikeYp(pharStockMedName);
	}
	@RequestMapping("/tocc_queryAllCheck")
	public @ResponseBody List<JlCheckProject> queryAllCheck(){
		return cchospeleService.queryAllCheck();
	}
	
	@RequestMapping("/tocc_queryOneCheck")
	public @ResponseBody JlCheckProject queryAllCheck(String cprId){
		return cchospeleService.queryOneCheck(Long.parseLong(cprId));
	}
	@RequestMapping("/tocc_queryOneElehosp")
	public @ResponseBody HospEleVo queryOneElehosp(String eleId){
		return cchospeleService.queryByEleId(new BigDecimal(eleId));
	}
	@RequestMapping("/tocc_queryByOneElehosp")
	public @ResponseBody CcHospitalElectronic queryByOneElehosp(String eleId){
		return cchospeleService.queryByOneEleId(new BigDecimal(eleId));
	}
	@RequestMapping("/tocc_queryByElepre")
	public @ResponseBody List<CcElectornicPrescribe> queryBElepre(String eleId){
		return cchospeleService.queryByElepre(new BigDecimal(eleId));
	}
	@RequestMapping("/tocc_queryByElepreCheck")
	public @ResponseBody List<CcElectornicCheck> queryBElepreCheck(String eleId){
		return cchospeleService.queryByElepreCheck(new BigDecimal(eleId));
	}
	@RequestMapping("/tocc_addhospEleprescribe")
	public @ResponseBody Result addhospEle(HospEleVo hospeleVo){
		if(hospeleVo !=null){
			cchospeleService.addHospEleVo(hospeleVo);
			return  new Result(true,"添加成功！");
		}else{
			return  new Result(false,"添加失败！");
		}
	}
	@RequestMapping("/tocc_addhospEleCheck")
	public @ResponseBody Result addhospEleCheck(CcHospCheckVo hospeleVo){
		if(hospeleVo !=null){
			cchospeleService.addCcHospCheckVo(hospeleVo);
			return  new Result(true,"添加成功！");
		}else{
			return  new Result(false,"添加失败！");
		}
	}
	@RequestMapping("/tocc_updatehospEle")
	public @ResponseBody Result updatehospEle(HospEleVo hospeleVo,long upele_id,String pritineid){
		if(hospeleVo !=null){
			hospeleVo.getChospele().setHeId(upele_id);
			//System.err.println(hospeleVo.getList().size());
			hospeleVo.getChospele().setHeSickid(new BigDecimal(pritineid));
			hospeleVo.getChospele().setHeType("开药");
			cchospeleService.addHospEleVo(hospeleVo);
			return  new Result(true,"修改成功！");
		}else{
			return  new Result(false,"修改失败！");
		}
	}
	@RequestMapping("/tocc_updatehospElecheck")
	public @ResponseBody Result updatehospElecheck(CcHospCheckVo hospeleVo,long upele_id,String pritineid){
		if(hospeleVo !=null){
			hospeleVo.getChospele().setHeId(upele_id);
			//System.err.println(hospeleVo.getList().size());
			hospeleVo.getChospele().setHeSickid(new BigDecimal(pritineid));
			hospeleVo.getChospele().setHeType("检查");
			cchospeleService.addCcHospCheckVo(hospeleVo);
			return  new Result(true,"修改成功！");
		}else{
			return  new Result(false,"修改失败！");
		}
	}
}